package com.bw.module_announcement.viewmodel

import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import com.bw.lib_common.base.BaseViewModel
import com.bw.module_announcement.model.AnnouncementModel
import com.bw.module_announcement.repoistory.AnnouncementRepository
import com.bw.module_announcement.repoistory.AnnouncementRepository_Factory
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject

@HiltViewModel
class AnnouncementViewModel@Inject constructor(private val repository: AnnouncementRepository): BaseViewModel() {

   private val announcementLiveData by lazy {
       MutableLiveData<AnnouncementModel>()
   }

    val announcementLiveData_:LiveData<AnnouncementModel> = announcementLiveData
    fun getAnnouncements(page:Int, size:Int){
        execute(
            action = repository.getAnnouncements(page, size),
            onFinish = {
                announcementLiveData.value=it.data
            }
        )
    }
}